package com.vertx.Thread;

import io.vertx.core.Vertx;
import io.vertx.ext.web.client.WebClient;

public class ThreadTest {

	public static void main(String[] args) {

		Vertx vertx = Vertx.vertx();

		String url = "/test/addNum";

		Thread thread1 = new Thread(() -> {
			WebClient client = WebClient.create(vertx);
			for (int i = 0; i < 100; i++) {

				client.get(8080, "localhost", url)
						.send()
						.onSuccess(response -> {
							System.out.println("thread1: onSuccess");
						})
						.onFailure(err -> {
							System.out.println("fail:" + err.getMessage());
						});

			}

		});
		thread1.start();

		Thread thread2 = new Thread(() -> {
			WebClient client = WebClient.create(vertx);
			for (int i = 0; i < 100; i++) {

				client.get(8080, "localhost", url)
						.send()
						.onSuccess(response -> {
							System.out.println("thread2: onSuccess");
						})
						.onFailure(err -> {
							System.out.println("fail:" + err.getMessage());
						});

			}
		});
		thread2.start();
	}

}
